const BaseHandler     = require('../base-handler');
const SystemServices  = require('../../../constants').SystemServices;
const HTTP_VERBS      = require('../../../constants').HTTP_VERBS;

class LogoutHandler extends BaseHandler {

    get needAuthenticated() {
        return false;
    }
    
    get pattern() {
        return "/logout";
    }

    doGET(request, response) {
        request.session.destroy((error, data) => {
            response.redirect('/login?ref=logout');
        });
    }

    setup() {
        this.registerVerb(HTTP_VERBS.GET, this.doGET);
    }
}

module.exports = LogoutHandler;